while True:
    try:
        # 字母表 List
        AphUpper    = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        AphLow      = AphUpper.lower()
        AphUpperList    = list(AphUpper)
        AphLowList      = list(AphUpper.lower())
        KEY = input().upper()
        Msg = input()
        KEY0 = ''
        for i in KEY:
            if i not in KEY0:
                KEY0 = KEY0 + i
        AphUppKEY = KEY0
        for i in AphUpperList:
            if i not in KEY0:
                AphUppKEY = AphUppKEY + i
        AphLowKEY = AphUppKEY.lower()
        AphUppKEYList = list(AphUppKEY)
        AphLowKEYList = list(AphLowKEY)
        Output = ''
        for i in Msg:
            if ord(i) >= 97:
                Output = Output + AphLowKEYList[AphLowList.index(i)]
            else:
                Output = Output + AphUppKEYList[AphUpperList.index(i)]
        print(Output)
    except:
        break